xilinx: Remove platform specific dependency from IPI function
authorJolly Shah <[email protected]>
Tue, 8 Jan 2019 19:27:36 +0000 (11:27 -0800)
committerJolly Shah <[email protected]>
Wed, 9 Jan 2019 20:12:18 +0000 (12:12 -0800)
ipi_mb function uses platform specific ipi configuration table.
These ipi_mb functions can be used for other Xilinx platform.
So, instead of using direct data structure, initialize IPI
configuration data by passing platform specific ipi table.
Macros are updated accordingly for this ipi table change.

This change is done so that ipi_mb functions can be moved to
common file without major changes. All common functions now would
be moved to common file in next patch.

Signed-off-by: Tejas Patel <[email protected]>
Reviewed-by: Siva Durga Prasad Paladugu <[email protected]>
Signed-off-by: Jolly Shah <[email protected]>
plat/xilinx/zynqmp/include/plat_ipi.h
plat/xilinx/zynqmp/sip_svc_setup.c
plat/xilinx/zynqmp/zynqmp_ipi.c

index 6d036afcc567ca90bc25f244cbd7de48dbedc524..15d7ab04e1b8b05462d93a2ac6f3822819bfc53b 100644 (file)
@@ -10,6 +10,7 @@
 #define PLAT_IPI_H
 
 #include <stdint.h>
+#include <ipi.h>
 
 /*********************************************************************
  * IPI agent IDs macros
 /*********************************************************************
  * IPI APIs declarations
  ********************************************************************/
+/* Configure IPI table for zynqmp */
+void zynqmp_ipi_config_table_init(void);
+
+/* Initialize IPI configuration table */
+void ipi_config_table_init(const struct ipi_config *ipi_table,
+                          uint32_t total_ipi);
 
 /* Validate IPI mailbox access */
 int ipi_mb_validate(uint32_t local, uint32_t remote, unsigned int is_secure);
index 5b8767988944786cb119481fd1b7ba19c73c9f72..edb81f5c3b333063c75ff8169d2e06575f1bf54b 100644 (file)
@@ -41,6 +41,9 @@ DEFINE_SVC_UUID2(zynqmp_sip_uuid,
  */
 static int32_t sip_svc_setup(void)
 {
+       /* Configure IPI data for ZynqMP */
+       zynqmp_ipi_config_table_init();
+
        /* PM implementation as SiP Service */
        pm_setup();
 
index ac84e0b7364b482006eec5aad8e44f0ffec77e2b..fd4804ddf663ca72291a014439ac897f79d09e47 100644 (file)
 #define IPI_IDR_OFFSET  0x1CU
 
 /* IPI register start offset */
-#define IPI_REG_BASE(I) (zynqmp_ipi_table[(I)].ipi_reg_base)
+#define IPI_REG_BASE(I) (ipi_table[(I)].ipi_reg_base)
 
 /* IPI register bit mask */
-#define IPI_BIT_MASK(I) (zynqmp_ipi_table[(I)].ipi_bit_mask)
+#define IPI_BIT_MASK(I) (ipi_table[(I)].ipi_bit_mask)
 
 /* IPI secure check */
 #define IPI_SECURE_MASK  0x1U
-#define IPI_IS_SECURE(I) ((zynqmp_ipi_table[(I)].secure_only & \
-                          IPI_SECURE_MASK) ? 1 : 0)
+#define IPI_IS_SECURE(I) ((ipi_table[(I)].secure_only & \
+                               IPI_SECURE_MASK) ? 1 : 0)
+
+/* IPI configuration table */
+const static struct ipi_config *ipi_table;
+
+/* Total number of IPI */
+static uint32_t ipi_total;
 
 /* Zynqmp ipi configuration table */
 const static struct ipi_config zynqmp_ipi_table[] = {
@@ -116,6 +122,29 @@ const static struct ipi_config zynqmp_ipi_table[] = {
        },
 };
 
+/**
+ * zynqmp_ipi_config_table_init() - Initialize ZynqMP IPI configuration data
+ *
+ */
+void zynqmp_ipi_config_table_init(void)
+{
+       ipi_config_table_init(zynqmp_ipi_table, ARRAY_SIZE(zynqmp_ipi_table));
+}
+
+/**
+ * ipi_config_table_init() - Initialize IPI configuration data
+ *
+ * @ipi_config_table  - IPI configuration table
+ * @ipi_total - Total number of IPI available
+ *
+ */
+void ipi_config_table_init(const struct ipi_config *ipi_config_table,
+                          uint32_t total_ipi)
+{
+       ipi_table = ipi_config_table;
+       ipi_total = total_ipi;
+}
+
 /* is_ipi_mb_within_range() - verify if IPI mailbox is within range
  *
  * @local  - local IPI ID
@@ -126,7 +155,6 @@ const static struct ipi_config zynqmp_ipi_table[] = {
 static inline int is_ipi_mb_within_range(uint32_t local, uint32_t remote)
 {
        int ret = 1;
-       uint32_t ipi_total = ARRAY_SIZE(zynqmp_ipi_table);
 
        if (remote >= ipi_total || local >= ipi_total)
                ret = 0;